defmodule <%= mod_name %>.Service do
  @moduledoc false
  use GRPC.Service, name: <%= inspect(name) %>

  <%= if not is_nil(desc) do %>
  def descriptor do
    # credo:disable-for-next-line
    <%= desc.__struct__ %>.decode(
      <%= desc.__struct__.encode(desc |> Map.from_struct() |> Enum.filter(fn {_, x} -> x != nil end) |> desc.__struct__.new()) |> inspect(limit: :infinity) %>
    )
  end
  <% end %>

<%= Enum.map methods, fn(method) -> %>
  rpc <%= method %>
<% end %>
end

defmodule <%= mod_name %>.Stub do
  @moduledoc false
  use GRPC.Stub, service: <%= mod_name %>.Service
end
